

import java.util.concurrent.*;

public class ThreadPoolDemo10 {


    public static void main(String[] args) {
        ThreadFactory factory=new ThreadFactory() {
            @Override
            public Thread newThread(Runnable r) {
                Thread thread=new Thread();
                return  thread;
            }
        };
        //手动方式创建线程池
        ThreadPoolExecutor executor=
                new ThreadPoolExecutor(5, 10, 10, TimeUnit.SECONDS,
                        new LinkedBlockingDeque<>(100), factory,
                        new ThreadPoolExecutor.DiscardPolicy());
    for(int i=0;i<10;i++){

        executor.submit(()->{

            System.out.println(Thread.currentThread().getName()+"执行任务");
        });
    }

    }
}
